#include "tan_stringobject.h"
#include <windows.h>

//#include "tan_funcmethod.h"
#include "time.h"
#include "tan_funcobject.h"
#include "tan_code_parser.h"
//#include "tan_code_snippet.hpp"

char* alloc_string(const char* string)
{
	char* rt_string = (char*)malloc(strlen(string) + 1);
	memset(rt_string, 0, strlen(string) + 1);
	memcpy(rt_string, string, strlen(string));
	return rt_string;
}

#include "tan_actuator.h"

int main(int argc, char* argv[])
{
	/*clock_t c = clock();
	TanList* list = find_args("1, (2+3, (4+5,6+(7*8))),ace(\"3,4\")");
	TanList* list = find_args("1, (2+3)");
	clock_t rc = clock();
	printf("run time: %d, begin time: %d, end time: %d\n", rc - c, c, rc);

	for (int i = 0; i < list->size; i++)
	{
		printf("[%s]\n", (char*)tan_list_at(list, i));
	}*/

	//find_if(0, "if(abc == 2)", 0);

	//char buffer[1024] = "var1, var2 = 3 * var1.function(var2, 1+2).function2(var3,var3.function3()), 1";


	//TANLIST(char*) codes = tan_list_create();

	//tan_list_push_back(codes, "class A : B {");
	//tan_list_push_back(codes, "	function text1 {");
	//tan_list_push_back(codes, "		push_back(1)");
	//tan_list_push_back(codes, "	}");
	//tan_list_push_back(codes, "}");

	///*tan_list_push_back(codes, "class A : B {");
	//tan_list_push_back(codes, "	function text1 {push_back(1)}");
	//tan_list_push_back(codes, "}aaaaa");*/

	////tan_list_push_back(codes, "class A : B {function text1 {push_back(1)}}class C : A {function text1 {push_back(2)}}");

	//int out_index = 0;
	//char* more = 0;
	//TANLIST(char*) rt_codes = scope_codes(codes, 0, &out_index, &more);

	//printf("out_index: %d\n", out_index);
	//for (int i = 0; i < rt_codes->size; i++)
	//{
	//	printf("code: %s\n", (char*)tan_list_at(rt_codes, i));
	//}
	//printf("more: %s\n", more);

	/*TANLIST(char*) list = tan_list_create();
	tan_list_push_back(list, alloc_string("class A : B {"));
	tan_list_push_back(list, alloc_string("	function text1(object1, object2) {"));
	tan_list_push_back(list, alloc_string("		var1++"));
	tan_list_push_back(list, alloc_string("	}"));
	tan_list_push_back(list, alloc_string("	function text2(object1){"));
	tan_list_push_back(list, alloc_string("		push_back(2)"));
	tan_list_push_back(list, alloc_string("	}"));
	tan_list_push_back(list, alloc_string("}"));
	parser_codes(list, "1");*/
	assert(argv != 1);

	tan_exec(tan_FileReadAll(argv[1]));
	return 0;
}